package com.zhitan.netty.enums;

public enum ControlTypeEnum {

    /**
     * 桩型号 0x01：立即执行  0x02：空闲执行
     */
    NOW((byte) 0x01, "立即执行"),
    FREE((byte) 0x02, "空闲执行");

    private byte code;
    private String message;

    ControlTypeEnum(byte code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(byte code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static ControlTypeEnum match(int key) {
        ControlTypeEnum result = null;
        for (ControlTypeEnum s : values()) {
            if (s.getCode() == key) {
                result = s;
                break;
            }
        }
        return result;
    }

    public static ControlTypeEnum catchMessage(String msg) {
        ControlTypeEnum result = null;
        for (ControlTypeEnum s : values()) {
            if (s.getMessage().equals(msg)) {
                result = s;
                break;
            }
        }
        return result;
    }
}
